package com.itbaizhan.listener;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/*测试HttpSession属性监听器
与HttpSessionAttrListener.java相关
* */
@WebServlet(urlPatterns = "/sessionAttr.do")
public class HttpSessionAttrServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取HttpSession对象
        HttpSession httpSession = req.getSession();
        //存放数据
        httpSession.setAttribute("key","Bjsxt");
        //替换数据
        httpSession.setAttribute("key","ITBZ");
        httpSession.removeAttribute("key");

    }
}
